import React, { memo, useEffect } from "react";
import { useHistory } from 'react-router-dom';
import { useSelector, shallowEqual, useDispatch } from "react-redux";
import RechTitle from '../../components/RechTitle'
import { getDetailsAction } from '../home/store/actionCreators'
import { BASE_URL } from '../../services/config'
import uploadImg from '../../assets/img/shangchuan.png'
import download from '../../assets/img/xiazai.png'
import css from './css.module.scss'
export default memo(function App() {
    const { details } = useSelector(
        (state) => ({
            details: state.getIn(["home", "details"]),
        }),
        shallowEqual
    );
    const dispatch = useDispatch();
    useEffect(() => {
        dispatch(getDetailsAction());
    }, [dispatch]);
    const handDownload = () => {
        window.open(BASE_URL + '/download/file?fileId=' + details.fileId)
        // downloadFile(details.fileId).then(res => {
        //     window.open(BASE_URL + '/download/file?fileId=' + details.fileId)
        // })
    }
    let history = useHistory();
    const handUpload = () => {
        history.push('/upload');
    }
    return (
        <div className='w ptb60'>
            <div style={{ marginBottom: "60px" }}>
                <RechTitle title='奖项说明' content={details.awardDescription}></RechTitle>
            </div>
            <RechTitle title='大赛申报流程' content={details.contestProcess}></RechTitle>
            <div className={css.du_imgs}>
                <img onClick={e => handDownload()} src={download} alt='下载' />
                <img onClick={e => handUpload()} src={uploadImg} alt='上传' />
            </div>
        </div>
    );
});
